<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function getBigNum(n1, n2) {
        //将字符串专程数组
        const num1 = n1.split("").reverse();
        const num2 = n2.split("").reverse();
        //循环的最大次数
        let length = Math.max(num1.length, num2.length);
        //设置进位
        let flag = 0;
        //设置数组接收结果
        let sumAll = [];
        //循环遍历数组
        for (let index = 0; index < length; index++) {
          let temp1 = num1.shift() || 0;
          let temp2 = num2.shift() || 0;
          let sum = Number(temp1) + Number(temp2) + flag;
          if (sum >= 10) {
            sum = sum % 10;
            flag = 1;
          } else {
            flag = 0;
          }
          sumAll.push(sum);
        }
        //由于计算是从个位数倒过来计算 所以返回结果也要翻转
        return sumAll.reverse().join("");
      }

      console.log(getBigNum("1232453746", "123871687"));
    </script>
  </body>
</html>
